package com.hoangkien.soundcloud.widget;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

public class IPopupWindown extends PopupWindow{
	private View view = null;

	public View getView() {
		return view;
	}


	public IPopupWindown(Context context, int res, ViewGroup group,
			boolean attachToRoot,int width,int height) {
		super(context);
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view = inflater.inflate(context.getResources().getLayout(res), group,
				attachToRoot);
		this.setWidth(width);
		this.setHeight(height);
		super.setContentView(view);
	}
	
	
	public void setIPopupDismissListenner(final IPopupWindownDismissListener dismissListener){
		this.setOnDismissListener(new OnDismissListener() {
			
			@Override
			public void onDismiss() {
				// TODO Auto-generated method stub
			
				if (dismissListener != null){
					dismissListener.opPopupDismiss();
				}
				
			}
		});
	}
	
	@SuppressWarnings("deprecation")
	public void setAutoHideOutside(){
		this.setBackgroundDrawable(new BitmapDrawable());
		this.setFocusable(true);
		this.setOutsideTouchable(true);
	}
	
	
}
